﻿//-----------------------------------------------------------------------
// <copyright file="HasMagicNumber.cs" company="None">
//     Copyright (c) 2009-2011
// </copyright>
//-----------------------------------------------------------------------

namespace CleanCode.StyleCopCustomRules.UnitTests.Resources
{
    using System;
    
    /// <summary>
    /// Dummy class to unit test the customized StyleCop rules.
    /// </summary>
    public class HasMagicNumber
    {
        /// <summary>
        /// Methods the has magic numbers.
        /// </summary>
        public void MethodHasMagicNumbers()
        {
            // TODO: Should this be reported? -> Currently it will be reported
            if (string.Empty.Length == 0)
            {
                Console.WriteLine("Zero length string.");
            }
            else
            {
                Console.WriteLine("String has a length greater than zero.");
            }

            // MagicNumber inside array will currently not be reported
            string[] stringArray = new string[11];

            // Unary shouldn't be reported
            int lastLineNumber = -2;

            // Should be reported (currently as two violations)
            int y = 3 + 4;

            // This part is only here to avoid a warning, that lastLineNumber is not used.
            Console.WriteLine(lastLineNumber);
            Console.WriteLine(y);
        }

        /// <summary>
        /// Second the method with magic numbers.
        /// </summary>
        public void SecondMethodWithMagicNumbers()
        {
            // Should be reported (currently as two violations)
            Console.WriteLine("Seconds per day: {0}", 3600 * 24);

            // Should be reported
            Console.WriteLine("Seconds per minute: {0}", 60);

            // Shouldn't be reported
            const int ConstantIntValue = 5;
            int x = ConstantIntValue;
            Console.WriteLine(x);

            // Declaration shouldn't be reported
            const int ArraySize = 6;
            var items = new int[ArraySize];

            // i=0 shouldnt violate, but 6 should
            for (int i = 0; i < 6; i++)
            {
                Console.WriteLine(i);
            }
        }
    }
}
